<?php

namespace app\ruinuo\config\database;
use app\common\model\RuinuoDatabase as DataMode;
class Info
{
    public function Model()
    {
        return new DataMode();
    }

    public function ListModel()
    {
        $Model=new DataMode();
        $DB=$Model->alias('a');
        return $DB;
    }

    public function InfoMode()
    {
        $data=[
            'app_id'=>'1',
            'app_num'=>'ruinuo',
            'app_name'=>'低代码',
            'mode_id'=>'6',
            'mode_num'=>'database',
            'mode_name'=>'数据库管理',
            'database'=>'ruinuo_database',
            'sub_database'=>[],        ];
        return $data;
    }

    public function InfoForm()
    {
        $data=[
            'power_field'=>[],
            'layout'=>[
                [
                    'field'=>'name',
                    'title'=>'表名',
                    'value'=>'',
                    'tag'=>'input',
                    'only'=>'1',
                    'required'=>'1',
                    'verify'=>'isalphaAndDash',
                ],
                [
                    'field'=>'comment',
                    'title'=>'注释',
                    'value'=>'',
                    'tag'=>'input',
                    'only'=>'2',
                    'required'=>'1',
                    'verify'=>'',
                ],
                [
                    'field'=>'engine',
                    'title'=>'引擎',
                    'value'=>'',
                    'tag'=>'select',
                    'only'=>'2',
                    'required'=>'1',
                    'verify'=>'',
                    'options_num'=>'database_engine',
                ],
                [
                    'field'=>'collation',
                    'title'=>'字符集',
                    'value'=>'',
                    'tag'=>'select',
                    'only'=>'2',
                    'required'=>'1',
                    'verify'=>'',
                    'options_num'=>'database_collation',
                ],
                [
                    'field'=>'old_name',
                    'title'=>'旧表名',
                    'value'=>'',
                    'tag'=>'input',
                    'only'=>'2',
                    'required'=>'2',
                    'verify'=>'',
                ],
                [
                    'field'=>'field',
                    'title'=>'字段',
                    'value'=>'',
                    'tag'=>'jsontable',
                    'only'=>'2',
                    'required'=>'2',
                    'verify'=>'',
                    'cols'=>[
                [
                    'field'=>'field',
                    'title'=>'字段名',
                    'update'=>'input',
                    'verify'=>'isalphaAndDash',
                    'required'=>'1',
                ],
                [
                    'field'=>'title',
                    'title'=>'注释',
                    'update'=>'input',
                    'required'=>'1',
                ],
                [
                    'field'=>'type',
                    'title'=>'字段类型',
                    'width'=>'',
                    'update'=>'select',
                    'options'=>'database_field_type',
                    'required'=>'1',
                ],
                [
                    'field'=>'length',
                    'title'=>'长度',
                    'update'=>'input',
                ],
                [
                    'field'=>'default',
                    'title'=>'默认值',
                    'update'=>'input',
                ],
                [
                    'field'=>'key',
                    'title'=>'索引',
                    'update'=>'switch',
                ],
            ],

                ],
            ],
        ];
        return $data;
    }

    public function InfoLists()
    {
        $data=[
            'lists'=>[
                [
                    'name'=>'全部',
                    'num'=>'m_1713270416',
                    'page_num'=>'30',
                    'order_raw'=>'id desc',
                    'power_field'=>[],
                    'power_role'=>'',
                    'power_department'=>'',
                    'set_where'=>'',
                    'table_cols'=>[
                [
                    'field'=>'id',
                    'title'=>'主键',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'name',
                    'title'=>'表名',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'like',
                    'total'=>'2',
                ],
                [
                    'field'=>'comment',
                    'title'=>'注释',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'like',
                    'total'=>'2',
                ],
                [
                    'field'=>'engine',
                    'title'=>'引擎',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'rows',
                    'title'=>'记录数',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'collation',
                    'title'=>'字符集',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'field_num',
                    'title'=>'字段数',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'update_id',
                    'title'=>'修改人',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
                [
                    'field'=>'update_time',
                    'title'=>'更新时间',
                    'update'=>'',
                    'options'=>'',
                    'search'=>'',
                    'total'=>'2',
                ],
            ],

                ],
            ],
        ];
        return !empty($data['lists']) ? $data['lists'] : [];
    }

}